$(function () {
    showBar1()
    showPie1()
    $('#companies-list li a').on('click', function () {
        $('#companies-list li a').removeClass('active');
        $(this).addClass('active');
    })
})

function showBar1() {
    var myChart = echarts.init(document.getElementById("bar1"));
    var option = {
        legend: {
            top: '10%',

            data: [
                '排查企业总数', '排查通过', '排查不通过'
            ],
            textStyle: {
                color: '#97B8C9',
                fontSize: 16
            }
        },
        tooltip: {
            trigger: 'axis',
            textStyle: {
                fontSize: 16
            }
        },
        grid: {
            top: '35%',
            left: '8%',
            bottom: '10%',
            containLabel: true
        },
        color: [
            '#3157EC', '#00CC57', '#EB3432'
        ],
        xAxis: {
            type: 'category',

            // boundaryGap: false,

            axisLine: {
                onZero: false,
                show: true,

                lineStyle: {
                    color: '#1178C9'
                }
            },
            axisLabel: {
                interval: 0,
                // rotate: -45,
                textStyle: {
                    color: '#97B8C9',
                    fontSize: 16

                }

            },
            axisLine: {
                lineStyle: {
                    color: '#07274D'
                }
            },
            axisTick: {
                lineStyle: {
                    color: '#1178C9'
                }
            },
            splitLine: {
                lineStyle: {
                    color: '#07274D'
                }
            },
            data: [
                '东阳市',
                '义乌市',
                '兰溪市',
                '磐安县',
                '浦江县',
                '武义县',
                '婺城区',
                '金东区',
                '永康市'

            ]
        },
        yAxis: [

            {
                type: 'value',
                interval: 0,
                splitLine: {
                    lineStyle: {
                        color: '#07274D'
                    }
                },
                axisLine: {
                    onZero: false,

                    lineStyle: {
                        color: '#07274D'
                    }
                },
                axisTick: {
                    lineStyle: {
                        color: '#1178C9'
                    }
                },
                axisLabel: {
                    textStyle: {
                        color: '#97B8C9',
                        fontSize: 16

                    },
                    formatter: '{value} '
                }
            }
        ],
        series: [{
            name: '排查企业总数',
            type: 'bar',

            stack: 0,

            itemStyle: {
                normal: {
                    barBorderRadius: 3
                }
            },
            data: [
                1,
                22,
                2,
                5,
                3,
                22,
                2,
                5,
                3

            ]

        }, {
            name: '排查通过',
            type: 'bar',
            stack: 1,
            itemStyle: {
                normal: {
                    barBorderRadius: 3
                }
            },
            // itemStyle: {
            //     normal: {
            //         color: function(value) {
            //             var coloeList = [
            //                 '#7630ED',
            //                 '#EB3432',
            //                 '#3157EC',
            //                 '#F2E52C',
            //                 '#21FB30',
            //                 '#FF8516',
            //                 '#4FE0FD',
            //                 '#DF31EB',
            //                 '#A5D571'
            //             ]
            //             return coloeList[value.dataIndex]
            //
            //         }
            //     }
            // },
            data: [
                1,
                22,
                2,
                5,
                3,
                22,
                2,
                5,
                23

            ]

        }, {
            name: '排查不通过',
            type: 'bar',
            stack: 1,
            itemStyle: {
                normal: {
                    barBorderRadius: 3
                }
            },
            data: [
                1,
                22,
                2,
                5,
                3,
                22,
                2,
                5,
                32

            ]

        }]
    };

    myChart.setOption(option);

}

function showPie1() {
    var myChart = echarts.init(document.getElementById("pie1"));
    var option = {
        tooltip: {
            trigger: 'item',
            formatter: "{a} <br/>{b}: {c} ({d}%)",
            textStyle: {
                fontSize: 16
            }
        },
        // legend: {
        //     orient: 'vertical',
        //     x: 'left',
        //     data: ['直接访问', '邮件营销', '联盟广告', '视频广告', '搜索引擎']
        // // },
        // tooltip: {
        //     formatter: '{b} {d}%'
        // },
        legend: {
            y: 'center',
            // top: '30%',
            left: '100px',

            width: 200,
            data: [
                '东阳市',
                '义乌市',
                '兰溪市',
                '磐安县',
                '浦江县',
                '武义县',
                '婺城区',
                '金东区',
                '永康市'

            ],
            textStyle: {
                color: '#97B8C9',
                fontSize: 16
            }
        },
        color: [
            '#4FE0FD',
            '#3157EC',
            '#F2E52C',
            '#7630ED',
            '#EB3432',
            '#A5D571',
            '#FF8516',
            '#21FB30',
            '#DF31EB'
        ],
        series: [{
            name: '排查不通过区域分布情况占比',
            type: 'pie',
            radius: [
                '28%', '60%'
            ],
            center: [
                '70%', '50%'
            ],
            avoidLabelOverlap: false,
            minAngle: 32,

            label: {
                normal: {
                    formatter: '{b} \n {d}%',
                    show: true,
                    textStyle: {
                        fontSize: 16,
                        color: '#97B8C9'
                    }

                },
                emphasis: {
                    show: true,
                    textStyle: {
                        fontSize: '14',
                        fontWeight: 'bold'
                    }
                }
            },
            labelLine: {
                normal: {
                    show: true
                }
            },
            data: [{
                value: 335,
                name: '东阳市'
            }, {
                value: 310,
                name: '义乌市'
            }, {
                value: 234,
                name: '兰溪市'
            }, {
                value: 135,
                name: '磐安县'
            }, {
                value: 1548,
                name: '浦江县'
            }, {
                value: 1548,
                name: '武义县'
            }, {
                value: 1548,
                name: '婺城区'
            }, {
                value: 1548,
                name: '金东区'
            }, {
                value: 1548,
                name: '永康市'
            }]
        }]
    };

    myChart.setOption(option);

}